#include "videoplayer.h"
#include "QMessageBox"

VideoPlayer* VideoPlayer::instance = 0;

VideoPlayer::VideoPlayer() : QVideoWidget()
{
    player = new QMediaPlayer(this);
    player->setVideoOutput(this);
    setFixedWidth(235);
    setMaximumHeight(200);
    setMinimumHeight(150);

    show();
}

VideoPlayer* VideoPlayer::get()
{
    if(instance == NULL)
        instance = new VideoPlayer;
    return instance;
}

void VideoPlayer::playSong(QUrl streamUrl)
{
    qDebug("starting play");
    streamUrl = QUrl(streamUrl.toString().remove("url="));
    qDebug(streamUrl.toString().toStdString().c_str());
    player->setMedia(streamUrl);
    player->play();
}
